#!/usr/bin/env python

import nltk
from nltk.corpus import brown
from nltk import FreqDist

brown_tagged_sents = brown.tagged_sents(categories='news')
brown_sents = brown.sents(categories='news')
size = int (len(brown_tagged_sents) * 0.9)
train_data = brown_tagged_sents[:size]
test_data = brown_tagged_sents[size:]

t0 = nltk.DefaultTagger('NN')
t1 = nltk.UnigramTagger(train_data,backoff=t0)
t2 = nltk.BigramTagger(train_data,backoff=t1)

# store
from pickle import dump
output = open('t2.pkl','wb')
dump(t2, output,-1)
output.close()